package com.pingan.generator.api.controller;

import java.util.HashMap;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.github.pagehelper.PageInfo;
import com.pingan.generator.api.entity.BaseLog;
import com.pingan.generator.api.entity.Pager;
import com.pingan.generator.api.entity.StatisticsInfo;
import com.pingan.generator.api.entity.util.Response;
import com.pingan.generator.api.service.StatisticsInfoService;

@RestController
// @RequestMapping("/statisticsInfo")
public class StatisticsInfoController extends BaseLog {

	@Autowired
	private StatisticsInfoService statisticsInfoService;

	//@RequestMapping(value="/saveStatisticsInfo",method = RequestMethod.POST)
	@SuppressWarnings("unchecked")
	public Response<StatisticsInfo> saveStatisticsInfo(@RequestBody StatisticsInfo statisticsInfo,
			HttpServletRequest request) {
		int count = statisticsInfoService.save(statisticsInfo);
		if (count > 1) {
			return Response.success(null);
		}
		return Response.failure();
	}

	 @SuppressWarnings("unchecked")
	 //@RequestMapping(value="/queryStatisticsInfoPagedList",method =RequestMethod.POST)
	 public Response<PageInfo<StatisticsInfo>>
	 queryStatisticsInfoPagedList(@RequestBody Pager pager){
	 if (pager.getParams() == null) {
	 pager.setParams(new HashMap<String, Object>());
	 }
	 return Response.success(statisticsInfoService.pagedList(pager));
	 }
	//
	// @SuppressWarnings("unchecked")
	// @RequestMapping(value = "/deleteStatisticsInfo", method =
	// RequestMethod.POST)
	// public Response<StatisticsInfo> deleteStatisticsInfo(@RequestBody
	// StatisticsInfo statisticsInfo, HttpServletRequest request) {
	// int count = statisticsInfoService.deleteById(statisticsInfo);
	// if(count>1){
	// return Response.success(null);
	// }
	// return Response.failure();
	// }
	//
	// @RequestMapping(value = "/deleteStatisticsInfoByKey", method =
	// RequestMethod.POST)
	// public Response<StatisticsInfo> deleteStatisticsInfoByKey(String id,
	// HttpServletRequest request) {
	// int count = statisticsInfoService.deleteById(id);
	// if(count>1){
	// return Response.success(null);
	// }
	// return Response.failure();
	// }
}
